<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        let nums = [26,16,98,41,93,38,90,64,12]
        // let nums = [16,26,98,41,93,38,90,64,12]

        // 通过冒泡排序调整数组元素位置，实现升序排列

        let count = 0;
        // 外层循环执行轮次
        //      + 对数组的每个元素做一次循环操作
        for (let i = 0; i < nums.length - 1; i++) {
            // 内层循环执行元素判断条件
            count++;
            for (let j = 0; j < nums.length -i - 1; j++) {
                count++;
                // console.log(nums[j],nums[j+1]);
                if(nums[j]>nums[j+1]){
                    let temp = nums[j];
                    nums[j] = nums[j+1];
                    nums[j+1] = temp;
                }
            }
        }
        console.log(nums);
        console.log(count);
        

    </script>
</head>
<body>
    
</body>
</html>